<?php
namespace My\Controller;

use Utuo\BackgroundController;

class DistributionShopAdController extends BackgroundController
{

    public function _initialize()
    {
        $this->setControllerTitle("广告内容管理");
        $this->setActionTitle(array(
            'index' => '广告内容列表',
            'add' => '广告内容添加',
            'modify' => '修改广告内容',
            'recycle' => '回收站'
        ));
        $this->setActionNav(array(
            'index',
            'add',
            'recycle'
        ));
    }

    public function getLists($is_deleted)
    {
        $condition = array(
            'cid' => $this->aid,
            'is_deleted' => $is_deleted
        );
        $m =  M('DistributionShopAd')->where($condition);
        $n = clone $m;
        $list = $m->page($this->getPage())->select();
        $count = $n->count();
        $this->showPage($count, $this->getPageSize());
        $this->assign('adLists', $list);
        $this->display();
    }

    public function addAction()
    {
        $this->display('save');
    }

    public function modifyAction($id)
    {
        $id = I("id", 0, "intval");
        $ad = M('DistributionShopAd')->where("cid=%d and id=%d", $this->aid, $id)->find();
        $this->assign("ad", $ad);
        $this->display('save');
    }
}